package leetcode.code1995;

import leetcode.IDebug;

/**
 * 执行用时：17 ms, 在所有 Java 提交中击败了58.84%的用户
 *
 * 内存消耗：36.4 MB, 在所有 Java 提交中击败了34.08%的用户
 *
 * 通过测试用例：211 / 211
 */
public class Solution2 implements IDebug {
	public int countQuadruplets(int[] nums) {
		int len = nums.length;
		int ans = 0;
		for (int i = 0; i < len - 3; i++) {
			for (int j = i + 1; j < len - 2; j++) {
				for (int m = j + 1; m < len - 1; m++) {
					for (int n = m + 1; n < len; n++) {
						if (nums[i] + nums[j] + nums[m] == nums[n]) {
							ans += 1;
						}
					}
				}
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
